<template>
  <div class="my-center-body">
    <div class="my-card">
      <!-- 图片div -->
      <div class="my-img-div">
        <div class="my-img-body">
          <img src="../../../assets/img/swapperlist/f1.jpg" alt="" />
        </div>
      </div>
      <div class="my-sign-div">
        <h2>Fang</h2>
        <span>love myself forever</span>
      </div>

      <div class="my-card-message">
        <el-card class="box-card">
          <div class="text item">
            <el-icon><User /></el-icon>{{ mylist.myname }}
          </div>
          <div class="text item">
            <el-icon><Star /></el-icon>{{ mylist.mybrithday }}
          </div>
          <div class="text item">
            <el-icon><Female /></el-icon>{{ usersexy }}
          </div>
          <div class="text item">
            <el-icon><Position /></el-icon>{{ mylist.myaddress }}
          </div>
          <div class="text item">
            <el-icon><Link /></el-icon>{{ mylist.mylearn }}
          </div>
        </el-card>
      </div>
    </div>
    <div class="card-setting">
      <h2 class="setting-h2">基本信息</h2>
      <el-form
        label-position="right"
        label-width="100px"
        :model="formLabelAlign"
        style="max-width: 320px"
      >
        <el-form-item label="姓名:">
          <el-input v-model="formLabelAlign.myname" class="input-name" />
        </el-form-item>
        <el-form-item label="生日:">
          <el-input v-model="formLabelAlign.mybrithday" />
        </el-form-item>
        <el-form-item label="性别:">
          <el-select
            v-model="formLabelAlign.mysexy"
            placeholder="请选择你的性别"
            style="width: 300px"
          >
            <el-option label="女" value="woman" />
            <el-option label="男" value="man" />
            <el-option label="保密" value="unknow" />
          </el-select>
        </el-form-item>
        <el-form-item label="地址:">
          <el-input v-model="formLabelAlign.myaddress" />
        </el-form-item>
        <el-form-item label="技能:">
          <el-input
            v-model="formLabelAlign.mylearn"
            type="textarea"
            :rows="3"
          />
        </el-form-item>
      </el-form>
      <el-button type="danger" @click="sumbitmymessage">保 存</el-button>
    </div>
  </div>
</template>

<script>
import { User, Star, Female, Position, Link } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";

export default {
  components: {
    User,
    Star,
    Female,
    Position,
    Link,
  },
  computed: {
    usersexy() {
      if (this.mylist.mysexy == "man") {
        return "男";
      }
      if (this.mylist.mysexy == "woman") {
        return "女";
      }
      if (this.mylist.mysexy == "unknow") {
        return "保密";
      }
      return this.mylist.mysexy;
    },
  },
  data() {
    return {
      mylist: {
        myname: "前端小白白",
        mybrithday: "2000/3/10",
        mysexy: "男",
        myaddress: "中国·广东省·深圳市",
        mylearn: "JavaScript、Html、Css、Vue",
      },
      formLabelAlign: {
        myname: "",
        mybrithday: "",
        mysexy: "",
        myaddress: "",
        mylearn: "",
      },
    };
  },
  methods: {
    sumbitmymessage() {
      if (this.formLabelAlign.myname == "") {
        ElMessage.warning("请输入名字！");
      } else {
        ElMessage.success("修改成功！");
        this.mylist.myname = this.formLabelAlign.myname;
        this.mylist.mybrithday = this.formLabelAlign.mybrithday;
        this.mylist.mysexy = this.formLabelAlign.mysexy;
        this.mylist.myaddress = this.formLabelAlign.myaddress;
        this.mylist.mylearn = this.formLabelAlign.mylearn;
      }
    },
  },
  created() {
    this.formLabelAlign.myname = this.mylist.myname;
    this.formLabelAlign.mybrithday = this.mylist.mybrithday;
    this.formLabelAlign.mysexy = this.mylist.mysexy;
    this.formLabelAlign.myaddress = this.mylist.myaddress;
    this.formLabelAlign.mylearn = this.mylist.mylearn;
  },
};
</script>

<style scoped>
.my-center-body {
  width: 100%;
  display: flex;
  justify-content: space-around;
  height: 100%;
  padding: 2%;
  /* background-color: yellow; */
}
.my-card {
  width: 30%;
  height: 600px;
  /* margin-right: 5%; */
  background-color: white;
}
.card-setting {
  width: 66%;
  height: 600px;
  /* margin-left: 2%; */
  background-color: white;
  box-sizing: border-box;
}
.my-img-div {
  width: 100%;
  height: 35%;
  /* margin-top: 10%; */
  /* background-color: red; */
  position: relative;
}
.my-img-body {
  width: 100px;
  height: 100px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 5px 3px 10px #999;
}
.my-img-body img {
  width: 100%;
  height: 100%;
  vertical-align: top;
  border-radius: 50%;
}
.my-sign-div {
  text-align: center;
}
.my-sign-div h2 {
  font-weight: 500;
  margin-bottom: 1%;
}
.my-sign-div span {
  font-size: 15px;
  letter-spacing: 1px;
  color: #666;
}
.el-card {
  /* background-color: yellow; */
  box-shadow: none;
  border: none;
}
.item {
  margin: 0 auto;
  padding: 5px 0;
  width: 55%;
  color: #666;
  font-size: 14px;
  /* background-color: green; */
}
.item .el-icon {
  margin-right: 3%;
}
.box-card {
  width: 100%;
}
.my-center-body > div {
  /* margin-top: 2%; */
}

.setting-h2 {
  margin: 0 auto;
  border-bottom: 2px solid #ccc;
  width: 95%;
  margin-top: 2%;
  padding-left: 2%;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
  color: #f34d37;
  background-color: white;
  height: 40px;
  line-height: 40px;
}
.el-form {
  margin-top: 20px;
  /* background-color: yellow; */
}
.el-button {
  width: 25%;
  margin-top: 3%;
  margin-left: 7.8%;
}
@media screen and (max-width: 821px) {
  .my-center-body {
    flex-direction: column;
  }
  .my-card {
    width: 95%;
    height: 500px;
  }
  .card-setting {
    width: 95%;
    height: 500px;
  }
  .my-img-div {
    margin-top: 3%;
  }
}
</style>